package br.uefs.dexa.rfframework.gui.config.dialogs;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;

public class ConfigDialogBottomPanel extends JPanel {
	
	private static final int MINIMUM_WIDTH = 500;
	
	private static final int MINIMUM_HEIGTH = 500;
	
	protected static final int BUTTON_WIDTH = 100;
	
	protected static final int BUTTON_HEIGTH = 30;
	
	private ConfigDialog parent;
	
	private JPanel buttonPanel;
	
	private JButton okButton;
	
	private JButton cancelButton;
	
	
	protected ConfigDialogBottomPanel(ConfigDialog parent)
	{
		this.parent = parent;
		init();
		configButtons();
	}
	
	private void init()
	{
		
		setLayout(new BorderLayout());
		
//		int borderThickness = ((80 - BUTTON_HEIGTH) / 2) - 5;
//		setBorder(BorderFactory.createEmptyBorder(borderThickness, borderThickness, borderThickness, borderThickness));
		
		okButton = new JButton("OK");
		cancelButton = new JButton("Cancel");
		
		buttonPanel = new JPanel();
		buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
		
		okButton.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGTH));
		cancelButton.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGTH));
		
		buttonPanel.add(okButton);
		buttonPanel.add(cancelButton);
		
		add(buttonPanel, BorderLayout.CENTER);
		
	}
	
	private void configButtons()
	{
		okButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				parent.okButtonAction();
				
			}
		});
		
		cancelButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				parent.cancelButtonAction();
				
			}
		});
	}

}
